const MyPromise = require('./myPromise')

const p = new MyPromise((resolve, reject) => {
    setTimeout (() => {
        resolve(100)
    }, 2000)
})
/* p.then(value => {
    console.log('1111111 '+value)
    return value
}, reason => {
    console.log(reason)
}).then(value => {
    console.log(value)
    return value
}).finally(() => {
    console.log('hahahaha')
}).then(value => {
    console.log('@@@@@@@@@@@@@@ '+value)
}) */

const posts = new MyPromise((resolve, reject) => {
    setTimeout(() => {
        reject('失败')
    }, 1000)
})
const urls = new MyPromise((resolve, reject) => {
    setTimeout(() => {
        resolve(200)
    }, 2000)
})
const users = new MyPromise((resolve, reject) => {
    setTimeout(() => {
        resolve(300)
    }, 3000)
})

Promise.race([posts, urls, users]).then(result => {
    console.log(result)
    return result
}, reason => console.log(reason)).then(value => {
    console.log(value)
    return value
})
